<template>
  <div>
    <el-upload
      :auto-upload="false"
      ref="uploads"
      action="https://jsonplaceholder.typicode.com/posts/"
      list-type="picture-card"
      :on-change="onsuccess"
      :limit="9"
      :file-list="fileList"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove"
    >
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisibles" :append-to-body="true">
      <img width="100%" :src="dialogImageUrl" alt="" />
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'CallPoliceElupload',
  props:{
    fileList:{
      type:Array,
      default:()=>[]
    }
  },
  data() {
    return {
      fileLists: [],
      dialogImageUrl: '',
      dialogVisibles: false
    }
  },

  mounted() {},

  methods: {
    // 图片上传成功
    onsuccess(response, fileList) {
      this.fileLists = fileList
      this.$emit('getuplodimg',this.fileLists)
    },
    // 图片查看
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisibles = true
    },
    // 图片删除
    handleRemove(response, fileList) {
      this.fileLists = fileList
      this.$emit('getuplodimg',this.fileLists)
    }
  }
}
</script>
